package com.itheima.controller;

import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    private UserService userService;
    @ResponseBody
    @GetMapping("user")
    public List<User> test(){
        List<User> userList = userService.selectAll();
        return userList;
    }
    @RequestMapping("users")
    public String toUser(Model model){
        List<User> userList = userService.selectAll();
        model.addAttribute("users",userList);
        return "users";
    }
}
